package com.ruoyi.syf.task;

import com.ruoyi.syf.mapper.RiskCheckDangerFixMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

/**
 * 隐患整改任务
 */
@Slf4j
@Component
public class DangerFixTask {

    @Autowired
    private RiskCheckDangerFixMapper fixMapper;

    /**
     * 每天0点15分执行
     * 将 超期未整改 的隐患状态修改为超期未整改
     */
    @Scheduled(cron = "0 15 0 * * ?")
    public void run(){
        List<Long> ids = fixMapper.getDangerFixTask();
        if (ids != null && ids.size() > 0){
            fixMapper.dangerFixTask(ids);
            log.info("修改隐患整改状态成功！修改数据：【{}】", ids);
        }
    }

}
